

//import com.sun.midp.io.ResourceInputStream;
//import com.sun.midp.lcdui.Resource;
import gene.core.Core;
import gene.core.sound.SoundPlayer;
//import demoScreen;
import java.applet.Applet;
import java.awt.Graphics;
import java.io.IOException;
import java.io.InputStream;
//import javax.microedition.midlet.*;
//import javax.microedition.lcdui.*;
//import javax.microedition.

public class Main extends Applet{ //extends MIDlet {

    private Core coreInstance;

    private static InputStream resource;

    //private Display d;

    //static private Display dip;

    //static Graphics g;
   
    private static final short W_H [ ] = { 600 , 400 };
    
    //private static final int H = 172;

    public static void main(String args[]){
        new Main();
    }

    public Main(){
        startApp();
    }


    public void pauseApp() {
        if(coreInstance!=null){
            coreInstance.pause();
        }else{startApp();}
    }

    public void destroyApp(boolean unconditional) {
        if( unconditional ){
        
        //dip.setCurrent(null);
        Core.graphics = null;
        //dip = null;
         //desaloca todo o jogo e chama o Coletor de lixo
        coreInstance.exit();
         
        }
       }
    
    public void startApp() {
    Core tmp;
      if(coreInstance == null){
      try{

       Core.InitEngine(W_H[0],W_H[1], false);
       coreInstance = Core.getInstance();

       //dip = Display.getDisplay( this );
       
       Core.InitEngine( W_H [ 0 ],W_H [ 1 ] , false);

       //Core.graphics = coreInstance.getCoreGraphics( );

       //dip.setCurrent( coreInstance );

       coreInstance.setScreen(new demoScreen());

      
       coreInstance.run( );
       
       //gameCanvas.clearMem( );

       destroyApp( true );

      }catch(Exception e){e.printStackTrace();}
        }
    }

    public void paint(Graphics g){

    }
}